package jk.spider.core.event.impl;

import java.util.Date;

import jk.spider.core.SpiderController;
import jk.spider.core.event.CoreEventVisitor;
import jk.spider.model.ProxyInfo;
import jk.spider.model.Resource;

public class URLSpideredProxyErrorEvent extends BaseCoreEventImpl {
	protected int httpStatus;
	protected String dTime;
	protected ProxyInfo proxyInfo;
	
	public URLSpideredProxyErrorEvent(SpiderController controller, Resource resource, ProxyInfo proxyInfo, int httpStatus) {
		super(controller, resource);
		this.httpStatus = httpStatus;
		this.proxyInfo = proxyInfo;
		proxyInfo.setError();
	}

	public void accept(Resource resource, CoreEventVisitor visitor) {
		visitor.visit(resource, this);
	}
	
	public ProxyInfo getProxyInfo() {
		return proxyInfo;
	}
	
	public int getHttpStatus() {
		return this.httpStatus;
	}
	
	@SuppressWarnings("deprecation")
	public String getDTime() {
		return new Date().toLocaleString();
	}
	
	public String getUrl() {
		return resource.getUrl();
	}
}
